<?php
@require_once("toubu.php");
$username = $_GET["username"];
$userpwd = $_GET["userpwd"];
$usertel = $_GET["usertel"];
$sql="SELECT * FROM userinfo WHERE username = '$username' or usertel = '$usertel' ";
$result=mysql_query($sql);//布尔值
$data=mysql_fetch_array($result);
//  echo json_encode($data);//集合
//   echo json_encode($data["0"]);//9
$obj = array();
if($data[0]>0){//用户存在
    $obj["code"]="0";
     $obj["msg"]="用户名或手机号重复";

}else{
$sqlx = "INSERT INTO userinfo(username,userpwd,usertel) VALUES ( '$username', '$userpwd','$usertel')";
 mysql_query($sqlx);
  $count = mysql_affected_rows();//获取受影响行数
  // echo $count;
  if($count>0) {//受影响行数为1是表示成功
    // 插入成功
    $obj["code"] = 1;
    $obj["msg"] = '注册成功';
   
}else{
    $obj["code"]="0";
    $obj["msg"]="注册失败"; 
}
}
echo json_encode($obj);
?>